home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gigarom 1
/
Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso
/
FILES
/
DEV
/
I-Z
/
ResExpress 1.0.sea
/
ResExpress 1.0
/
ResX DevKit
/
How to write externals
< prev
next >
Wrap
Text File
|
1991-07-06
|
8KB
|
230 lines
How to write ResX Externals.
There are two types of ResX externals:
RXVW (ResX View)
- These are externals that view or edit a SPECIFIC type of resource such
as an ICON editor or MENU editor. When installed, it will hilite the
'View' button if a resource of that type is selected.
RXXT (ResX External)
- These are externals that can apply to ANY type of resource such as a
Hex Editor or Resource Duplicator. Externals also do not have to act
on a resource. They could do virtually any function even not related to
a resource. A FEdit like external or Data Fork copier are examples.
____________________________________________________________
The following is generalized info for writing externals. For specific
instructions, see the RXVW/RXXT Shells and ResX Utils.p. Detailed guidlines
are provided in the shells.
Writing 'RXVW's -
When ResX launches a RXVW, it passes a handle of the current selected
resource to the external code resource. If several resources are selected,
ResX will pass in the handle one resource at a time. When writing a 'RXVW',
it is not necessary to handle ALL selected resources, ResX will do that
for you. Just write the external as if only one resource is selected.
The resource is NOT loaded so it is necessary to LoadResource(ResHandle) if needed. The resource is NOT detached!
ResX's global environment is also accessible if needed. See below.
Writing 'RXXT's -
These are executed from the 'External' menu. If a resource is selected, the
handle of the resource is passed in and the same rules apply as for 'RXVW's.
Global Environment -
SettingsHandle contains Configuration setup, last and second to last files
opened, and last move info.
SettingsHandle = ^SettingsPtr;
SettingsPtr = ^SettingsRec;
SettingsRec = record
unused1: Boolean;
openStartup: Boolean;
sortTList, sortRList: Boolean;
lastOneRefNum, lastTwoRefNum: integer;
lastOneName, lastTwoName: Str255;
lastMoveType: ResType;
lastMoveID: integer;
lastMoveSource, lastMoveDest: Str255;
onStartup: integer;
unused2: integer;
dClick: integer;
helpFName: Str255;
end;
unused1: Boolean;
- Used internally. Do not alter.
openStartup: Boolean;
- If set, the configuration options are enabled from the Configuration.
sortTList, sortRList: Boolean;
- If sortTlist is set, the Type lists will be sorted alphanumerically.
- If sortRlist is set, the Resource lists will be sorted alphanumerically.
lastOneRefNum, lastTwoRefNum: integer;
- Volume reference numbers of the last and second to last files that
were opened from ResX.
lastOneName, lastTwoName: Str255;
- File names of last and second to last files that were opened from ResX.
- This includes the entire path to the file. (Poor Mans Search Path)
lastMoveType: ResType;
- Resource type of the last resource that has been copied.
- This is used in the 'Repeat Last Copy' option.
lastMoveID: integer;
- Resource ID of the last resource copied.
- This is used in the 'Repeat Last Copy' option.
lastMoveSource, lastMoveDest: Str255;
- Source and Destination Files of the last resource copied.
- This is used in the 'Repeat Last Copy' option.
onStartup: integer;
- Open on startup options.
- If equal to 1, the last file is opened.
- If equal to 2, the last two files are opened.
- If equal to 3, the open file dialog is opened.
unused2: integer;
- Used internally. Do not alter.
dClick: integer;
- Current selected item of DoubleClick popup menu.
- If set to 1, Copy is enabled.
- If set to 2, Get Info is enabled.
- If set to 3, View is enabled.
- If set to 4, Remove is enabled.
helpFName: Str255;
- Location of the master Help file.
_________________________________________________________
GlobalsHndl = ^GlobalsPtr;
GlobalsPtr = ^GlobalsRec;
GlobalsRec = record
theDevCtlEnt: DCtlPtr;
- Device Control Entry for the DA. Do not alter.
rsrcBase: Integer;
- Resource Base of the DA. Do not alter.
daMenu: MenuHandle;
- Handle to the DA menu. This can be altered to be used with an external
but replace the orginal menu when finished.
daFileID: Longint;
- File ID of the DA.
LeftFName, RightFName: Str255;
- Path and Name of Left & Right files currently opened.
LeftVNum, RightVNum: integer;
- Volume reference numbers of Left & Right files
LWasOpened, RWasOpened: Boolean;
- Left/Right file was opened priorly and shouldn't be closed.
LcurType, RcurType: ResType;
- Current TYPE displayed above resource lists
LTcurCell, RTcurCell: Cell;
- Current selected cell in Left/Right TYPE list.
LRcurCell, RRcurCell: Cell;
- Current selected cell in Left/Right RESOURCE list
LfileID, RfileID: integer;
- Left/Right File IDs.
prefsID: integer;
- File ID of ResX Prefs in the System Folder
- If your external needs to store preferences or hold data, store it in
this file as a resource. Use UniqueID() and name the resource the
same as your external or view.
CompactLeft, CompactRight: Boolean;
- Left/Right resource map will be compacted when closed if TRUE
- If a resource is removed for either file, it should be compacted.
favMenu, extMenu, openMenu: MenuHandle;
- Favorite File/Externals/Open File MenuHandles. Do not alter.
Lopen, Ropen: Boolean;
- True if Left/Right file is open and displayed in ResX
MFActive: Boolean;
- True if MultiFinder is running
Settings: SettingsHandle;
- Handle to Settings in Configuration setup
LTypeList: ListHandle; {Handle to Left Type list}
RTypeList: ListHandle; {Handle to Right Type list}
LResList: ListHandle; {Handle to Left Resource list}
RResList: ListHandle; {Handle to Right Resource list}
Info: ControlHandle; {Get Info Button Control Handle}
View: ControlHandle; {View Button Control Handle}
OpenLeft: ControlHandle; {Open Left Button Control Handle}
OpenRight: ControlHandle; {Open Right Button Control Handle}
Remove: ControlHandle; {Remove Button Control Handle}
Copy: ControlHandle; {Copy Button Control Handle}
• ResX Utilities -
A toolbox of utilities is included that provide some functions to simplify
writing externals. It also provides direct access to ResX's Alerts.
There are three Alerts inside of ResX. Pass in a message or question to
these alerts and they will use the Alert resources and routines inside of
ResX to call the alert. It is not necessary to include these resources in
the project. This simplifies writing externals a great deal and gives a
consistent interface for all externals.
• OKAlert(message: Str255);
Pass in the message to alert the user. An alert will appear with the
message with an OK button.
• OKCancel(message: Str255): Boolean;
Pass in the message to alert the user. An alert will appear with the
message and OK and Cancel buttons.
OK returns TRUE, Cancel returns FALSE.
• YesNoCancel(question: Str255): integer;
Pass in the question to ask the user. An alert will appear with the
question and Yes, No, and Cancel buttons.
Yes returns 1, No returns 0, Cancel returns -1
The Super Memory Manager-
This is a combination of the Standard Handle routines and TempHandle
routines. Is uses proper Memory Manager calls and is not home made
handles thus is safe to use.
It's purpose is to provide more memory for externals. In DA's, externals
get needed memory from the System Heap. Unfortunately, when trying
to create a NewHandle, the SysHeap will not expand into the FreeMem heap.
SuperHandles uses the FreeMem heap via a TempHandle if there is not
enough memory in the SysHeap that is requested. If there is enough
memory in the SysHeap, a standard handle is created in that heap.
If a large handle size requested is not available in either heap, it will
create a handle at %90 of the available memory in either heap, whichever
is greater.
See ResX Utils.p or ResX Utils.h for more info.